const path = require("path");
const config = require("../../config");
const { JmxWorker } = require("../../src/jmxGeneration");

const MEDICAL_RECORD_CREATION = "01.建档";
const REGISTRATION = "02.挂号";
const OUTPATIENT_DOCTOR = "03.门诊医生";
const CHARGE = "04.收费";
const DRUG_DISPENSING = "05.发药";
const ADMISSION = "06.入院";
const WARD_ADMISSION = "07.入区";
const INPATIENT_DOCTOR = "08.住院医生";
const INPATIENT_NURSE = "09.住院护士";
const INPATIENT_NURSE_EXEC_ORDER = "10.住院护士_执行医嘱";
const EMERGENCY_DOCTOR = "11.急诊医生";

const harPath = path.resolve(config.path.data, "debug", "har");
const jmxPath = path.resolve(config.path.data, "debug", "jmx");
const testPlanNames = [INPATIENT_DOCTOR];

(function () {
    const jmxWorker = new JmxWorker({ "host": "127.0.0.1", "port": 6379, "db": 0 });
    for (let i = 0; i < testPlanNames.length; i++) {
        const testPlanName = testPlanNames[i];
        let harFilterConfigs = [];
        let inputConfigs = [];
        let outputConfigs = [];
        let headerConfig = null;
        let forcedRequestConfigs = [];
        let forcedResponseConfigs = [];
        let mapRequestConfigs = [];
        let mapResponseConfigs = [];
        let customRequestConfigs = [];
        let ignoreRequestConfigs = [];
        let ignoreResponseConfigs = [];
        let stepConfigs = [];
        switch (testPlanName) {
            case MEDICAL_RECORD_CREATION:
                harFilterConfigs = config.harFilterConfig.winex.medicalRecordCreation;
                inputConfigs = config.jmx.winex.medicalRecordCreation.inputConfigs;
                outputConfigs = config.jmx.winex.medicalRecordCreation.outputConfigs;
                headerConfig = config.jmx.winex.medicalRecordCreation.headerConfig;
                forcedRequestConfigs = config.jmx.winex.medicalRecordCreation.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.medicalRecordCreation.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.medicalRecordCreation.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.medicalRecordCreation.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.medicalRecordCreation.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.medicalRecordCreation.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.medicalRecordCreation.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.medicalRecordCreation;
                break;
            case REGISTRATION:
                harFilterConfigs = config.harFilterConfig.winex.registration;
                inputConfigs = config.jmx.winex.registration.inputConfigs;
                outputConfigs = config.jmx.winex.registration.outputConfigs;
                headerConfig = config.jmx.winex.registration.headerConfig;
                forcedRequestConfigs = config.jmx.winex.registration.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.registration.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.registration.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.registration.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.registration.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.registration.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.registration.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.registration;
                break;
            case OUTPATIENT_DOCTOR:
                harFilterConfigs = config.harFilterConfig.winex.outpatientDoctor;
                inputConfigs = config.jmx.winex.outpatientDoctor.inputConfigs;
                outputConfigs = config.jmx.winex.outpatientDoctor.outputConfigs;
                headerConfig = config.jmx.winex.outpatientDoctor.headerConfig;
                forcedRequestConfigs = config.jmx.winex.outpatientDoctor.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.outpatientDoctor.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.outpatientDoctor.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.outpatientDoctor.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.outpatientDoctor.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.outpatientDoctor.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.outpatientDoctor.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.outpatientDoctor;
                break
            case ADMISSION:
                harFilterConfigs = config.harFilterConfig.winex.admission;
                inputConfigs = config.jmx.winex.admission.inputConfigs;
                outputConfigs = config.jmx.winex.admission.outputConfigs;
                headerConfig = config.jmx.winex.admission.headerConfig;
                forcedRequestConfigs = config.jmx.winex.admission.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.admission.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.admission.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.admission.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.admission.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.admission.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.admission.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.admission;
                break
            case WARD_ADMISSION:
                harFilterConfigs = config.harFilterConfig.winex.wardAdmission;
                inputConfigs = config.jmx.winex.wardAdmission.inputConfigs;
                outputConfigs = config.jmx.winex.wardAdmission.outputConfigs;
                headerConfig = config.jmx.winex.wardAdmission.headerConfig;
                forcedRequestConfigs = config.jmx.winex.wardAdmission.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.wardAdmission.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.wardAdmission.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.wardAdmission.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.wardAdmission.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.wardAdmission.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.wardAdmission.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.wardAdmission;
                break
            case INPATIENT_DOCTOR:
                harFilterConfigs = config.harFilterConfig.winex.inpatientDoctor;
                inputConfigs = config.jmx.winex.inpatientDoctor.inputConfigs;
                outputConfigs = config.jmx.winex.inpatientDoctor.outputConfigs;
                headerConfig = config.jmx.winex.inpatientDoctor.headerConfig;
                forcedRequestConfigs = config.jmx.winex.inpatientDoctor.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.inpatientDoctor.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.inpatientDoctor.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.inpatientDoctor.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.inpatientDoctor.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.inpatientDoctor.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.inpatientDoctor.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.inpatientDoctor;
                break;
            case INPATIENT_NURSE:
                harFilterConfigs = config.harFilterConfig.winex.inpatientNurse;
                inputConfigs = config.jmx.winex.inpatientNurse.inputConfigs;
                outputConfigs = config.jmx.winex.inpatientNurse.outputConfigs;
                headerConfig = config.jmx.winex.inpatientNurse.headerConfig;
                forcedRequestConfigs = config.jmx.winex.inpatientNurse.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.inpatientNurse.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.inpatientNurse.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.inpatientNurse.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.inpatientNurse.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.inpatientNurse.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.inpatientNurse.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.inpatientNurse;
                break;
            case INPATIENT_NURSE_EXEC_ORDER:
                harFilterConfigs = config.harFilterConfig.winex.inpatientNurseExecOrder;
                inputConfigs = config.jmx.winex.inpatientNurseExecOrder.inputConfigs;
                outputConfigs = config.jmx.winex.inpatientNurseExecOrder.outputConfigs;
                headerConfig = config.jmx.winex.inpatientNurseExecOrder.headerConfig;
                forcedRequestConfigs = config.jmx.winex.inpatientNurseExecOrder.forcedRequestConfigs;
                forcedResponseConfigs = config.jmx.winex.inpatientNurseExecOrder.forcedResponseConfigs;
                mapRequestConfigs = config.jmx.winex.inpatientNurseExecOrder.mapRequestConfigs;
                mapResponseConfigs = config.jmx.winex.inpatientNurseExecOrder.mapResponseConfigs;
                customRequestConfigs = config.jmx.winex.inpatientNurseExecOrder.customRequestConfigs;
                ignoreRequestConfigs = config.jmx.winex.inpatientNurseExecOrder.ignoreRequestConfigs;
                ignoreResponseConfigs = config.jmx.winex.inpatientNurseExecOrder.ignoreResponseConfigs;
                stepConfigs = config.stepConfig.winex.inpatientNurseExecOrder;
                break;
            default:
                break;
        }
        jmxWorker.work(harPath, harFilterConfigs, jmxPath, testPlanName, inputConfigs, outputConfigs, headerConfig, forcedRequestConfigs, forcedResponseConfigs, mapRequestConfigs, mapResponseConfigs, customRequestConfigs, ignoreRequestConfigs, ignoreResponseConfigs, stepConfigs);
    }
})()
